#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

struct TreeNode* invertTree(struct TreeNode* root) {

    if (root == NULL)

    {

        return NULL;

    }



    struct TreeNode* left = invertTree(root->left);

    struct TreeNode* right = invertTree(root->right);

    root->left = right;

    root->right = left;



    return root;

}

typedef struct BinaryTree

{

    char val;

    struct BinaryTree* left;

    struct BinaryTree* right;

}BTNode;



BTNode* TreeCreate(char* str, int* pi)

{

    if (str[*pi] == '#')

    {

        ++(*pi);

        return NULL;

    }

    BTNode* root = (BTNode*)malloc(sizeof(BTNode));

    root->val = str[(*pi)++];

    root->left = TreeCreate(str, pi);

    root->right = TreeCreate(str, pi);



    return root;

}



void InOrder(BTNode* root)

{

    if (root == NULL)

    {

        return;

    }

    InOrder(root->left);

    printf("%c ", root->val);

    InOrder(root->right);

}



int main()

{

    char str[100];

    gets(str);

    int i = 0;

    BTNode* root = TreeCreate(str, &i);

    InOrder(root);

    return 0;

}